define(function (require, exports, module) {
    const Constants = require('./constants.js').onload();

    function onload() {
        function isEnterKey(e) {
            return e.keyCode === 13;
        }

        function isEscapeKey(e) {
            return e.keyCode === 27;
        }

        function isVertex(e) {
            const featureTarget = e.featureTarget;
            if (!featureTarget) return false;
            if (!featureTarget.properties) return false;
            return featureTarget.properties.meta === Constants.meta.VERTEX;
        }

        function noTarget(e) {
            return e.featureTarget === undefined;
        }

        function isOfMetaType(type) {
            return function (e) {
                const featureTarget = e.featureTarget;
                if (!featureTarget) return false;
                if (!featureTarget.properties) return false;
                return featureTarget.properties.meta === type;
            };
        }

        function isActiveFeature(e) {
            if (!e.featureTarget) return false;
            if (!e.featureTarget.properties) return false;
            return e.featureTarget.properties.active === Constants.activeStates.ACTIVE &&
                e.featureTarget.properties.meta === Constants.meta.FEATURE;
        }

        function isInactiveFeature(e) {
            if (!e.featureTarget) return false;
            if (!e.featureTarget.properties) return false;
            return e.featureTarget.properties.active === Constants.activeStates.INACTIVE &&
                e.featureTarget.properties.meta === Constants.meta.FEATURE;
        }

        function isShiftDown(e) {
            if (!e.originalEvent) return false;
            return e.originalEvent.shiftKey === true;
        }

        function isShiftMousedown(e) {
            if (!e.originalEvent) return false;
            if (!e.originalEvent.shiftKey) return false;
            return e.originalEvent.button === 0;
        }

        function isFeature(e) {
            if (!e.featureTarget) return false;
            if (!e.featureTarget.properties) return false;
            return e.featureTarget.properties.meta === Constants.meta.FEATURE;
        }

        return {
            noTarget,
            isOfMetaType,
            isActiveFeature,
            isInactiveFeature,
            isShiftDown,
            isEnterKey,
            isEscapeKey,
            isShiftMousedown,
            isFeature,
            isVertex
        }
    }

    module.exports = {
        onload
    }
});
